﻿using System.Linq;
using FoodRaidersWebAPI.domainnew.other;
using FoodRaidersWebAPI.Models;

namespace FoodRaidersWebAPI.Service.Second
{
    public class RaiderService
    {
        private readonly FoodContext context;

        public RaiderService(FoodContext context)
        {
            this.context = context;
        }
        //删除
        public Raider delete(int id)
        {
            var raider = findByID(id);
            context.Raiders.Remove(raider);
            context.SaveChanges();
            return raider;
        }
        //id查询
        public Raider findByID(int id)
        {
            return context.Raiders.FirstOrDefault(R => R.RaiderID == id);
        }
    }
}